package com.boot;


import cn.hutool.db.sql.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Queue;

@SpringBootApplication
@RestController
public class MainBoot {

    @Autowired
    private  MongoTemplate mongoTemplate;


    @GetMapping("/code")
    public String code(String code) {
        return code;
    }



    @GetMapping("/hello")
        public Student hello(HttpServletRequest request, HttpServletResponse response) throws IOException {
            //String url  = "http://127.0.0.1:8080/oauth/authorize?response_type=code&client_secret=secret&client_id=appid";
            //response.sendRedirect(url);
          // List<Student> list = mongoTemplate.findAll(Student.class);
           //list.forEach(e->System.out.println(e));
        //Query query = new Query();

        Student stu = mongoTemplate.findById("2",Student.class);
         return stu;
//          Student stu  = new Student();
//          stu.setId("2");
//          stu.setName("李四");
//          stu.setAge(20);
//          mongoTemplate.save(stu);
         // return null;
        }

    public static void main(String[] args) {
        SpringApplication.run(MainBoot.class);
    }
}
